home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / pump_src / plasma.c < prev    next >
C/C++ Source or Header  |  1995-10-26  |  2KB  |  83 lines

  1. // Image Plasma
  2.  
  3. #include "pump.h"
  4.  
  5. byte (*origin)[64000];               // Original Picture
  6.  
  7. void loadscreen(char *fname, byte *dest)
  8. {
  9.     JCLIB_Load(fname, dest, 64000);
  10. }
  11.  
  12. void loadpalette (char *fname)
  13. {
  14.     JCLIB_Load(fname, GL_Pal, 768);
  15. }
  16.  
  17. void degrade()
  18. {
  19.     int x, y, pos;
  20.     byte *p;
  21.  
  22.     p = LLS_Screen[0];
  23.     pos=320;
  24.     for (x=0; x<320; x++) {
  25.         for (y=1; y<199; y++) {
  26.             *p++ =(GL_WorkScreen[pos+320] + GL_WorkScreen[pos-320] + GL_WorkScreen[pos+1] + GL_WorkScreen[pos-1]) >> 2;
  27.             pos++;
  28.          }
  29.     }
  30. }
  31.  
  32. void dumpscreen(int incx, int incy, byte *orig)
  33. {
  34.     int x,y,pos,dif;
  35.  
  36.     dif=incx+incy*320;
  37.     pos=0;
  38.     for (y=0;y<170; y++) {
  39.       for (x=0;x<319; x++) {
  40.         if (orig[pos]!=0)
  41.             LLS_Screen[0][pos+dif]=orig[pos];
  42.         pos++;
  43.       }
  44.     }
  45. }
  46.  
  47. void DoPlasma(void) {
  48.     int i,j;
  49.     int f = 0;
  50.     bool leave = FALSE;
  51.  
  52.     j=0;
  53.     origin = NEW(4*64000);
  54.     loadscreen("iguana.pix",origin[0]);
  55.     loadscreen("party.pix",origin[1]);
  56.     loadscreen("coding.pix",origin[2]);
  57.     loadscreen("rulez.pix",origin[3]);
  58.     loadpalette("iguana.pal");
  59.     VBL_DumpPalette(GL_Pal, 0, 256);
  60.     memset(LLS_Screen[0], 0, LLS_Size);
  61.     memcpy(GL_WorkScreen, origin[0], 64000);
  62.     while (!LLK_SpacePressed && !leave) {
  63.       for (i=0; !leave && i < 5; i++) {
  64.         if (DVTInfo != NULL && DVTInfo->semaphores[3]) {
  65.             DVTInfo->semaphores[3]--;
  66.             leave = TRUE;
  67.         } else if (DVTInfo == NULL && f > 5*70)
  68.             leave = TRUE;
  69.         degrade();
  70.         memcpy(GL_WorkScreen, LLS_Screen[0], 64000);
  71.         LLS_Update();
  72.         f += VBL_VSync(1);
  73.       }
  74.  
  75.        if (j==3) j=-1;
  76.        j++;
  77.        dumpscreen(0,0,origin[j]);
  78.        memcpy(GL_WorkScreen, LLS_Screen[0], 64000);
  79.     }
  80.     DISPOSE(origin);
  81. }
  82.  
  83.